#include "geometry.h"

int main() 
{
	int n, m;
	point in_p;
	std::vector<point> points;
	std::cin >> n;
	points.resize(n);

	for (int i = 0; i < n; i++) 
	{
		std::cin >> in_p.x >> in_p.y;
		points[i] = in_p;
	}

	std::cin >> m;
	for (int i = 0; i < m; i++) 
	{
		std::cin >> in_p.x >> in_p.y;
		int k = 0;
		for (int j = 1; j < n; ++j) 
			if (dist(points[j], in_p) < dist(points[k], in_p))
				k = j;
		std::cout << points[k].x << " " << points[k].y << "\n";
	}

	return 0;
}